package com.shioirikukuri.service;

import com.shioirikukuri.domain.OperateIntegralVo;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

@LocalTCC
public interface IUsableIntegralServiceTCC {

    /**
     * 积分支付,扣减指定用户积分
     * @param vo
     * @return
     */
    @TwoPhaseBusinessAction(name="payTry",commitMethod = "payConfirm",rollbackMethod = "payCancel",useTCCFence = true)
    Boolean payTry(@BusinessActionContextParameter("vo") OperateIntegralVo vo, BusinessActionContext context);

    void payConfirm(BusinessActionContext context);
    void payCancel(BusinessActionContext context);

    /**
     * 积分退款,给指定用户添加积分
     * @param vo
     */
    @TwoPhaseBusinessAction(name="refundTry",commitMethod = "refundConfirm",rollbackMethod = "refundCancel",useTCCFence = true)
    void refundTry(@BusinessActionContextParameter("vo") OperateIntegralVo vo, BusinessActionContext context);

    void refundConfirm(BusinessActionContext context);

    void refundCancel(BusinessActionContext context);
}
